From 1f382abd67502fce916d5ed9f97b83df6d654729 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Wed, 2 Oct 2013 03:55:13 +0000 Subject: [PATCH] Bring in some of the straight-forward pieces from NEW_STRINGS work. --- gpsbabel/mkshort.cc | 6 ++++++ gpsbabel/xol.cc | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gpsbabel/mkshort.cc b/gpsbabel/mkshort.cc index 8c95f871a..cd1a8aa9d 100644 --- a/gpsbabel/mkshort.cc +++ b/gpsbabel/mkshort.cc @@ -572,6 +572,12 @@ mkshort(short_handle h, const char* istring) return ostring; } +char * +mkshort(short_handle h, const QString& istring) +{ + return mkshort(h, CSTR(istring)); +} + /* * As above, but arg list is a waypoint so we can centralize * the code that considers the alternate sources. diff --git a/gpsbabel/xol.cc b/gpsbabel/xol.cc index 702f50f03..24e612d3c 100644 --- a/gpsbabel/xol.cc +++ b/gpsbabel/xol.cc @@ -54,7 +54,6 @@ xg_tag_mapping xol_map[] = { { NULL, (xg_cb_type)0, NULL } }; - static void xol_overlay(xg_string args, const QXmlStreamAttributes* attrv) { @@ -167,7 +166,11 @@ xol_fatal_outside(const waypoint* wpt) { gbfprintf(fout, "#####\n"); fatal(MYNAME ": %s (%s) is outside of convertable area \"%s\"!\n", +#if NEW_STRINGS + wpt->shortname.isEmpty() ? "Waypoint" : CSTRc(wpt->shortname), +#else wpt->shortname ? CSTRc(wpt->shortname) : "Waypoint", +#endif pretty_deg_format(wpt->latitude, wpt->longitude, 'd', NULL, 0), gt_get_mps_grid_longname(grid_swiss, MYNAME)); } @@ -183,11 +186,11 @@ xol_write_time(const waypoint* wpt) } static void -xol_write_string(const char* name, const char* str) +xol_write_string(const QString& name, const QString& str) { - if (str && *str) { + if (!str.isEmpty()) { QString temp = strenquote(str, '"'); - gbfprintf(fout, " %s=%s", name, CSTR(temp)); + gbfprintf(fout, " %s=%s", CSTR(name), CSTR(temp)); } } @@ -226,10 +229,9 @@ static void xol_waypt_disp_cb(const waypoint* wpt) { double x, y; - const char* name; - name = wpt->shortname; - if ((name == NULL) || (*name == '\0') || global_opts.synthesize_shortnames) { + QString name = wpt->shortname; + if (name.isEmpty() || global_opts.synthesize_shortnames) { name = mkshort_from_wpt(short_h, wpt); } else { name = mkshort(short_h, name); @@ -255,8 +257,6 @@ xol_waypt_disp_cb(const waypoint* wpt) gbfprintf(fout, "%*s\n", space*2, "", x, y); gbfprintf(fout, "%*s\n", --space*2, ""); gbfprintf(fout, "%*s\n", --space*2, ""); - - xfree(name); } static void -- 2.30.2